<?php

namespace app\common\validate;

use think\Validate;
use think\Request;

class Article extends Validate
{
    protected $rule = [
        'title' => 'require',
        'cover' => 'require',
        'content' => 'require'
    ];

    protected $message = [
        'title.require' => '标题不能为空',
        'cover.require' => '封面图片不能为空',
        'content.require' => '内容不能为空'
    ];

    protected $scene = [
        'edit'  =>  ['title'],
        'edit'  =>  ['content'],
        'edit'  =>  ['cover']
    ];

    protected function checkCode($value)
    {
        $code = Request::instance()->session('code');
        if ($code != $value) {
            return '验证码输入错误';
        } else {
            return true;
        }
    }
}